#include <stdio.h>
#include <stdlib.h>

/** Biref Description
 * Description
 * @param 
 * @see 
 * @return 
 */

int bin2dec (int *array)
{
    int ans, multi, i;

    ans = 0;
    multi = 1;
    for (i = 7; i >= 0; i--) {
        ans += array[i] * multi;
        multi *= 2;
    }

    return ans;
}

int main (int argc, char const* argv[])
{
    int n, array[8], i, j, start;
    char buf[32];

    scanf("%d", &n);
    while (n--) {
        scanf("%s", buf);
        for (i = 0; i < 4; i++) {
            start = i * 8;
            for (j = 0; j < 8; j++) {
                array[j] = buf[start + j] - '0';
            }
            printf("%d", bin2dec(array));
            if (i < 3) {
                printf(".");
            }
        }
        printf("\n");
    }

    return 0;
}
